import {INCREMEMTCOUNT,DECREMEMTCOUNT} from '../constant/countConst'

const init = {
  count: 0
}



export default function countReducer(prevState = init, action) {

  //接收action对象的type和data
  const { type, data } = action
  // console.log('reducer被调用了',type, data,prevState);

  // console.log('reducer被调用了',type, data);
  switch (type) {
    case INCREMEMTCOUNT:
      return { ...init, count: prevState.count + data }
    case DECREMEMTCOUNT:
      return { ...init, count: prevState.count - data }
  }

  return prevState
}